package org.huamoxi.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.List;

@Data
@NoArgsConstructor
public class LoginUser implements UserDetails {

    Long id;

    String account;

    String username;

    String password;

    private List<GrantedAuthority> authorities; // 权限列表

    public LoginUser (Long id, String account, String username, String password, List<GrantedAuthority> authorities) {
        this.id = id;
        this.account = account;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
    }

    @Override
    public List<GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    } // 账号未过期

    @Override
    public boolean isAccountNonLocked() {
        return true;
    } // 账号未被锁定

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    } // 凭证(密码) 未过期

    @Override
    public boolean isEnabled() {
        return true;
    } // 可用
}
